-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit Test for FAR Controller #11
Unit Test for FAR Controller #11
Conversation
razo7
commented
Feb 16, 2023
•
edited
Loading
edited
- Create new controllers suite for testing with Ginkgo commands.
- Add Ginkgo target.
- Refactor Executer
- Unit Test the build of CLI command and functionality tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So.... I left "some" comments already. But before even understanding the actual test, I discovered a huge mistake in this operator. Looking further into the unit test does not make sense with it:
The FenceAgentsRemediationTemplate's spec should only have a template.spec
field which refers to the spec of FenceAgentsRemediation. Everything else needs to go into the latter. See SNR template as an example.
@slintes IIUC this is a mistake because that makes the naming/convention very confusing (i.e the FAR isn't an imaged of the FAR Template). |
ex, err := cli.NewExecuter(pod) | ||
//TODO: Check that FA is excutable? run cli.IsExecuteable | ||
|
||
r.Log.Info("Create and execute the fence agent", "Fence Agent", farTemplate.Spec.Agent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: IMO this log is an overkill for each time reconcile is triggered.
(Keep in mind that we already have a log in the executor that has this info an more)
44bc759
to
db14701
Compare
Using Ginkgo commands to bootsrap a new suite - controllers_test
Add Ginkgo target and run it with extra flags instead of go test, since Ginkgo has additional capabilities that can only be accessed via ginkgo
Simplify the code rather than using an hook function
New suite and mockExcuter to mock production code using Executor
First unit-test to FAR
db14701
to
67edf66
Compare
5bcd2f7
to
1f78a64
Compare
make test failed on Github CI
1f78a64
to
703089c
Compare
Previously it has been stored in a global variable
The code is better readable
069bfc0
to
9cee882
Compare
9fb7929
to
da25926
Compare
Better testing of buildFenceAgentParams result
da25926
to
22ab7e9
Compare
Better testing of a real agent or a non empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding this test resulted in much better code in the end. Also the test itself evolved nice over time. Good work!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: razo7, slintes The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |